fix(datepicker): collapse month/year grid after selection#39
Conversation
NgdsCalendar drove its *ngIf views off the @input() displayDepth, which round-trips through NgdsCalendarManager — leaving the date grid and the month/year grid visible at once. Track view depth in a local updated directly in the calendar's own click handlers so its *ngIf re-evaluates immediately; still emit changeDepth/Month/Year for nav. Also widen NgdsDropdown.dropdownClasses to string | string[].
|
Heads up — this looks solid for single datepickers, but it regresses the two-calendar range picker. The single-datepicker fix is correct: owning view depth locally so the The problem is in
Root cause is the dual source of truth: child-local Also minor: Single-calendar configs ( |
|
calendar.component.ts:
calendar.component.html:
ngds-dropdown.component.ts:
|
…g month/year view
|
i have pushed another update, addressing the concerns above: previously each calendar owned its view depth locally, while the manager kept its own displayDepth and assumed both calendars moved together, so toggling one didn't move the other, and the manager's depth no longer matched what was on screen. Fix lifts the depth back to NgdsCalendarManager as the single source of truth. It now pushes the depth into both calendars synchronously whenever it changes (via @ViewChildren → a setDepth() on the calendar), so the two stay in lockstep. The per-calendar local write in the click handlers stays, so the clicked calendar still collapses its grid synchronously, the push just brings the other one along in the same tick. Because both calendars actually follow the depth again, the end-calendar offset in toggleDepth and the arrow step unit in changeDisplayByValue are correct without any changes to that maths. Specifics:
I tested it by running the ng serve in |
NgdsCalendar drove its *ngIf views off the @input() displayDepth, which round-trips through NgdsCalendarManager — leaving the date grid and the month/year grid visible at once. Track view depth in a local updated directly in the calendar's own click handlers so its *ngIf re-evaluates immediately; still emit changeDepth/Month/Year for nav.
Also widen NgdsDropdown.dropdownClasses to string | string[].
Fixes the issue: bcgov/reserve-rec-public#569